unit dmda_StockPlace;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, dmModule, DB, FR_DSet, FR_DBSet, ADODB;

type
  Tdtmda_StockPlace = class(TdtmModule)
    adsStock: TADODataSet;
    adsMasterEditHasUse2: TBooleanField;
    adsMasterEditHasStop2: TBooleanField;
    adsMasterEditRemark2: TStringField;
    adsMasterEditStopDate: TDateTimeField;
    adsMasterEditStoper2: TStringField;
    adsMasterEditStopMemo2: TStringField;
    adsMasterEditWriter2: TStringField;
    adsMasterEditWriteTime2: TDateTimeField;
    adsMasterEditModifyTime2: TDateTimeField;
    adsMasterEditModifier2: TStringField;
    adsMasterEditHasCheck2: TBooleanField;
    adsMasterEditCheckTime2: TDateTimeField;
    adsMasterEditChecker2: TStringField;
    adsMasterEditHasSysDefine: TBooleanField;
    adsMasterEditHasDefault: TBooleanField;
    adsMasterHasStop: TBooleanField;
    adsMasterHasUse: TBooleanField;
    adsMasterHasSysDefine: TBooleanField;
    adsMasterHasDefault: TBooleanField;
    adsMasterStoper: TStringField;
    adsMasterStopDate: TDateTimeField;
    adsMasterStopMemo: TStringField;
    adsMasterHasCheck: TBooleanField;
    adsMasterChecker: TStringField;
    adsMasterCheckTime: TDateTimeField;
    adsMasterWriter: TStringField;
    adsMasterWriteTime: TDateTimeField;
    adsMasterModifier: TStringField;
    adsMasterModifyTime: TDateTimeField;
    adsMasterRemark: TStringField;
    adsMasterEditDeptID: TStringField;
    adsUserCompany: TADODataSet;
    adsMasterDeptID: TStringField;
    adsDepartment: TADODataSet;
    adsMasterEditres_DeptName: TStringField;
    adsMasterEditPosID: TStringField;
    adsMasterEditPosName: TStringField;
    adsMasterEditStockID: TStringField;
    adsMasterPosID: TStringField;
    adsMasterPosName: TStringField;
    adsMasterStockID: TStringField;
    res_Stock: TADODataSet;
    adsMasterEditres_StockName: TStringField;
    adsMasterStockCode: TStringField;
    adsMasterEditPosNo: TStringField;
    adsMasterPosNo: TStringField;
    procedure adsMasterEditNewRecord(DataSet: TDataSet);
    procedure adsMasterEditPosNoChange(Sender: TField);
  private
    { Private declarations }
  protected
    procedure ModuleInit;override;
    procedure OpenEditDataSet; override;
  public
    { Public declarations }
    FStockID: string;
  end;

var
  dtmda_StockPlace: Tdtmda_StockPlace;

implementation

uses uGlobal,uMsgBox,uShare, uConst, uSQL, dmConnect;

{$R *.dfm}

{ Tdtmda_StockPlace }

procedure Tdtmda_StockPlace.ModuleInit;
begin
  FUniqueTable := 'da_StockPlace';
  inherited;
end;  

procedure Tdtmda_StockPlace.OpenEditDataSet;
begin
  FMasterEditTable := 'da_StockPlace';
  FMasterKeyField := 'PosID';
  inherited;
end;

procedure Tdtmda_StockPlace.adsMasterEditNewRecord(DataSet: TDataSet);
begin
  inherited;
  if (adsMasterEdit.State in [dsInsert, dsEdit]) and (FStockID<>'') then
  begin
    adsMasterEdit.FieldByName('StockID').ReadOnly := False;
    adsMasterEdit.FieldByName('StockID').AsString := FStockID;
  end;
end;

procedure Tdtmda_StockPlace.adsMasterEditPosNoChange(Sender: TField);
begin
  inherited;
  if (adsMasterEdit.State in [dsInsert, dsEdit]) then
  begin
    adsMasterEdit.FieldByName('PosName').ReadOnly := False;
    adsMasterEdit.FieldByName('PosName').AsString := Sender.AsString;
  end;
end;

end.

